<html>
<head lang="en">
    <title>首页</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css">
    <link rel="stylesheet" href="/css/index.css">


    <script>
        $(function () {
            showComments();
            //==================================
            //发送ajax请求,获取到当前周推荐的游记
            $.get("/travels/commends", {type: 1}, function (data) {
                $("#travelsCommends").renderValues({list: data}, {
                    handle: function (ele, val) {
                        ele.href = "/travelContent.html?id=" + val;
                    }
                });
                //默认选择第一个来显示
                $(".carousel-item:first").addClass("active");
            });
        });

        function showComments() {
            var Mar = document.getElementsByClassName("Marquee")[0];
            var child_div = Mar.getElementsByTagName("div");
            var picH = 50;//移动高度
            var scrollstep = 3;//移动步幅,越大越快
            var scrolltime = 20;//移动频度(毫秒)越大越慢
            var stoptime = 3000;//间断时间(毫秒)
            var tmpH = 0;
            Mar.innerHTML += Mar.innerHTML;

            function start() {
                if (tmpH < picH) {
                    tmpH += scrollstep;
                    if (tmpH > picH) tmpH = picH;
                    Mar.scrollTop = tmpH;
                    setTimeout(start, scrolltime);
                } else {
                    tmpH = 0;
                    Mar.appendChild(child_div[0]);
                    Mar.scrollTop = 0;
                    setTimeout(start, stoptime);
                }
            }

            setTimeout(start, stoptime);
        }



    </script>



</head>

<body>

<div class="body">
    <input type="checkbox" id="menu">

    <label for="menu" class="menu">
        <span><i class="fa fa-user fa-fw fa-2x"></i></span>
        <span><i class="fa fa-chevron-left fa-fw fa-2x" style="color: #3E3C3B"></i></span>
    </label>

    <!-- 侧边栏 -->
    <div class="nav">
        <iframe id="ipage" src="/mine/simpleProfiles.html" frameborder="0" width="90%"></iframe>
    </div>

    <div class="search-head">
        <div class="row nav-search">
            <div class="col-2"></div>
            <div class="col-10">
                <div class="input-group-sm search">
                    <input class="form-control searchBtn" placeholder="搜索旅行攻略、日记和旅游资讯">
                </div>
            </div>
        </div>
    </div>

    <div class="container">
        <h6 class="module-title">每周推荐</h6>
        <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
            <div id="travelsCommends">
                <div class="carousel-inner" render-loop="list">

                    <div class="carousel-item">
                        <a render-key="list.travelId" render-fun="handle">
                            <img class="d-block w-100" width="100%" height="200px"
                                 render-src="list.coverUrl">
                            <span class="recommend" render-html="list.title"></span>
                        </a>
                    </div>

                </div>
            </div>
            <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only"></span>
            </a>
            <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only"></span>
            </a>
        </div>
        <hr>

<!--新增-->
       <!-- <a href="root/index.html">旅游小siri</a>-->

        <div class="row nav-box">
            <div class="col" style="background-color: #DFE823;" align="center">
                <a href="/strategyPage.html"><i class="fa fa-plane fa-fw"></i> 找攻略</a>
            </div>
            <div class="col" style="background-color: #7281D5;" align="center">
                <a href="/travelPage.html"><i class="fa fa-book fa-fw"></i> 看游记</a>
            </div>
        </div>
        <div class="row nav-box">
            <div class="col" style="background-color: #0d8f5e;" align="center">
                <a href="/hotel/hotel.html"><i class="fa fa-fw fa-hotel"></i> 找酒店</a>
            </div>
            <div class="col" style="background-color: #ff8800;" align="center">
                <a href="/ticket/ticket.html"><i class="fa fa-car fa-fw"></i> 找景点</a>
            </div>
        </div>
        <div class="row nav-box">
            <div class="col" style="background-color: #03A9F4;" align="center">
                <a href="/shop/index.html"><i class="fa fa-fw fa-shopping-basket "></i> 逛商城</a>
            </div>
            <div class="col" style="background-color: #494A5F;" align="center">
                <a href="/root/index.html"><i class="fa fa-fw fa-user-o"></i> 小助手</a>
            </div>
        </div>
        <div class="row nav-box">
            <div class="col" style="background-color: #20c997;" align="center">
                <a href="/news/index.html"><i class="fa fa-fw fa-newspaper-o "></i> 看新闻</a>
            </div>
            <div class="col" style="background-color: #6f42c1;" align="center">
                <a href="https://apip.weatherdt.com/h5.html?id=1qGcf1ICsP"><i class="fa fa-fw fa-tint"></i> 查天气</a>
            </div>
        </div>

        <div class="row dynamic " id="comments">
            <div class="col-1" style="padding: 0px;">
                <img class="rounded" src="/img/topComment.png" style="width: 50px;">
            </div>
            <div class="col">
                <div class="Marquee" render-loop="list">
                    <div class="d-flex">
                        <a href="/userProfiles.html">
                            <img class="rounded-circle dynamic-head" render-src="list.user.headImgUrl">
                        </a>
                        <a class="dynamic-detail" render-key="list.id" render-fun="handle">
                            <span render-html="list.user.nickName"></span> 点评了攻略<p render-html="list.stratagy.title"></p>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <hr>

    <div class="container">
        <h6 class="module-title">骡窝头条日报<a href="newsPage.html">更多</a></h6>
        <div class="news " id="bigger">
            <a role="button" render-key="id" render-fun="handle">
                <img width="100%" render-src="coverUrl">
                <div class="caption">
                    <h5 render-html="title"></h5>
                    <p render-html="subTitle"></p>
                </div>
            </a>
        </div>

        <hr>
        <h6 class="module-title">最新推荐</h6>
        <div id="smaller">
            <div style="margin-bottom: 20px" render-loop="list">
                <a role="button" render-key="list.id" render-fun="handle">
                    <div class="row news-detail">
                        <div class="col-5">
                            <img width="100%" render-src="list.coverUrl">
                        </div>
                        <div class="col-7">
                            <h4 render-html="list.title"></h4>
                            <p render-html="list.subTitle"></p>
                        </div>
                    </div>
                    <hr>
                </a>
                <hr>
            </div>
        </div>
    </div>
</div>
<script>
    $(function(){
        //1:渲染骡窝头条日报
        $.get("/dailyDetails", {state: 1}, function (data) {
            $("#bigger").renderValues(data, {
                handle: function (ele, val) {
                    ele.href = "/newsContent.html?id=" + val;
                }
            });
        });

        //2:渲染推荐日报
        $.get("/dailyDetails/commends", {state: 2}, function (data) {

            $("#smaller").renderValues({list: data}, {
                handle: function (ele, val) {
                    ele.href = "/newsContent.html?id=" + val;
                }
            });
        });


    });

</script>
</body>
<script>
    //发送ajax请求获取所有攻略的评论
    $.get("/comments", {stratagyType: 0}, function (data) {
        $("#comments").renderValues(data,{
            handle: function (ele, val) {
                ele.href = "/comment/strategyComment.html?id=" + val;
            }});
    });



</script>
</html>